import {always, buildMenu} from "@/utils/permission";

export function menuApprove(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0185', 'approve', '/approve', 'noRedirect', 'Layout', '工作流', 'approve')
    o.children.push(menuApproveInformation(permissionCodes))
    o.children.push(menuApproveConfig(permissionCodes))
    o.children.push(menuApproveProcess(permissionCodes))
    o.children.push(menuApproveProcessing(permissionCodes))
    o.children.push(menuApproveTask(permissionCodes))
    return o
}

function menuApproveInformation(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0186', 'information', 'information', 'noRedirect', 'ParentView', '信息维护', 'resource')
    o.children.push(buildMenu(permissionCodes, 'PD0191', 'expression', 'expression', '', 'bpm/information/bpmExpression/index', '表达式', 'expression'))
    o.children.push(buildMenu(permissionCodes, 'PD0192', 'listener', 'listener', '', 'bpm/information/bpmListener/index', '监听器', 'listener'))
    return o
}

function menuApproveConfig(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0187', 'configure', 'configure', 'noRedirect', 'ParentView', '审批配置', 'resource')
    o.children.push(buildMenu(permissionCodes, 'PD0193', 'relation', 'relation', '', 'bpm/configure/bpmRelation/index', '工作流关系', 'relation'))
    o.children.push(buildMenu(permissionCodes, 'PD0194', 'approver', 'approver', '', 'bpm/configure/bpmApprover/index', '审批人员选择', 'select'))
    o.children.push(buildMenu(permissionCodes, 'PD0195', 'assignee', 'assignee', '', 'bpm/configure/bpmAssignee/index', '默认待办人', 'default'))
    return o
}

function menuApproveProcess(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0188', 'process', 'process', 'noRedirect', 'ParentView', '流程管理', 'resource')
    o.children.push(buildMenu(permissionCodes, '', 'model', 'model', '', 'bpm/process/bpmModel/index', '流程模型', 'model'))
    o.children.push(buildMenu(permissionCodes, always, 'design', 'design', '', 'bpm/process/bpmModel/model', '流程设计', ''))
    o.children.push(buildMenu(permissionCodes, '', 'deployment', 'deployment', '', 'bpm/process/bpmDeployment/index', '部署模型', 'deploy'))
    return o
}

function menuApproveProcessing(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0189', 'processing', 'processing', 'noRedirect', 'ParentView', '流程监控', 'resource')
    o.children.push(buildMenu(permissionCodes, '', 'underway', 'underway', '', 'bpm/processing/bpmUnderway/index', '进行中的流程', 'ing'))
    o.children.push(buildMenu(permissionCodes, '', 'over', 'over', '', 'bpm/processing/bpmOver/index', '已结束的流程', 'end'))
    return o
}

function menuApproveTask(permissionCodes) {
    let o = buildMenu(permissionCodes, 'PD0190', 'processed', 'processed', 'noRedirect', 'ParentView', '任务管理', 'resource')
    o.children.push(buildMenu(permissionCodes, '', 'submit', 'submit', '', 'bpm/processed/bpmSubmit/index', '我提交的', 'submit'))
    o.children.push(buildMenu(permissionCodes, '', 'todo', 'todo', '', 'bpm/processed/bpmTodo/index', '待办任务', 'todo'))
    o.children.push(buildMenu(permissionCodes, '', 'did', 'did', '', 'bpm/processed/bpmDid/index', '已办任务', 'did'))
    return o
}
